#include <iostream>
#include <vector>
using namespace std;

const int N = 1e5 + 10;

int n, q;
vector<int> a[N];

int main()
{
	cin >> n >> q;
	while(q--)
	{
		int op, i, j; cin >> op >> i >> j;
		if(op == 1)
		{
			int k; cin >> k;
			if(a[i].size() <= j) a[i].resize(j + 1); // 扩容
			if(k == 0) a[i][j] = 0; // 清空格子
			else a[i][j] = k;
		}
		else if(op == 2)
		{
			cout << a[i][j] << endl;
		}
	}

	return 0;
}